﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="LessonSelectionManagement.ascx.cs" Inherits="TeachingAffairsManagementSystem.UserControl.RightContent.Admin.LessonSelectionManagement" %>
<%@ Register Src="~/WebControl/AlertBox.ascx" TagPrefix="uc1" TagName="AlertBox" %>


<uc1:AlertBox runat="server" ID="Alert"/>
<div id="search">
    <div class="form-group">
        <div class="input-group">

            <asp:TextBox ID="TBSearch" runat="server" CssClass="form-control"></asp:TextBox>
            <div class="input-group-btn">
                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">查询 <span class="caret"></span></button>
                <ul class="dropdown-menu">
                    <li>
                        <asp:LinkButton ID="LBSearchAll" runat="server" OnClick="LBSearchAll_Click">全部</asp:LinkButton>
                    </li>
                    <li>
                        <asp:LinkButton ID="LBSearchL_ID" runat="server" OnClick="LBSearchL_ID_Click">课程ID</asp:LinkButton>
                    </li>
                    <li>
                        <asp:LinkButton ID="LBSearchT_ID" runat="server" OnClick="LBSearchT_ID_Click">教师ID</asp:LinkButton>
                    </li>
                    <li>
                        <asp:LinkButton ID="LBSearchS_ID" runat="server" OnClick="LBSearchS_ID_Click">学生ID</asp:LinkButton>
                    </li>

                </ul>
            </div>

        </div>
    </div>
</div>

<div id="gridview">
    <div class="form-group">
        <asp:GridView ID="GVLessonSelection" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="student_s_id,lesson_l_id,lesson_teacher_t_id" DataSourceID="DSLessonSelection" OnRowUpdating="GVLessonSelection_RowUpdating" CssClass="table table-bordered table-hover" OnRowDeleted="GVLessonSelection_RowDeleted" OnRowUpdated="GVLessonSelection_RowUpdated" ShowHeaderWhenEmpty="True">
            <Columns>
                <asp:BoundField DataField="student_s_id" HeaderText="学生ID" ReadOnly="True" SortExpression="student_s_id"/>
                <asp:BoundField DataField="s_name" HeaderText="学生名称" ReadOnly="True" SortExpression="s_name"/>
                <asp:BoundField DataField="lesson_l_id" HeaderText="课程ID" ReadOnly="True" SortExpression="lesson_l_id"/>
                <asp:BoundField DataField="l_name" HeaderText="课程名称" ReadOnly="True" SortExpression="l_name"/>
                <asp:TemplateField HeaderText="分数" SortExpression="score">
                    <EditItemTemplate>
                        <asp:TextBox CssClass="form-control" ID="TextBox1" runat="server" Text='<%# Bind("score") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("score") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="lesson_teacher_t_id" HeaderText="教师ID" ReadOnly="True" SortExpression="lesson_teacher_t_id"/>
                <asp:BoundField DataField="t_name" HeaderText="教师名称" ReadOnly="True" SortExpression="t_name"/>
                <asp:BoundField DataField="finished" HeaderText="已结束" ReadOnly="True" SortExpression="finished"/>
                <asp:BoundField DataField="create_time" HeaderText="加入时间" ReadOnly="True" SortExpression="create_time"/>
                <asp:TemplateField ShowHeader="False">
                    <EditItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="更新"></asp:LinkButton>
                        &nbsp;
                        <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Delete" Text="删除"></asp:LinkButton>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit" Text="编辑"></asp:LinkButton>

                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <EmptyDataTemplate>
                无结果
            </EmptyDataTemplate>
        </asp:GridView>
    </div>
</div>


<asp:SqlDataSource ID="DSLessonSelection" runat="server" ConnectionString="<%$ ConnectionStrings:sitedbConnectionString %>"
                   DeleteCommand="DELETE FROM student_has_lesson WHERE student_s_id = ? AND lesson_l_id = ? AND lesson_teacher_t_id = ?"
                   ProviderName="<%$ ConnectionStrings:sitedbConnectionString.ProviderName %>"
                   SelectCommand="SELECT * FROM view_student_has_lesson"
                   UpdateCommand="UPDATE student_has_lesson SET score = ? WHERE student_s_id = ? AND lesson_l_id = ? AND lesson_teacher_t_id = ?">
    <DeleteParameters>
        <asp:Parameter Name="student_s_id" Type="Int32"/>
        <asp:Parameter Name="lesson_l_id" Type="Int32"/>
        <asp:Parameter Name="lesson_teacher_t_id" Type="Int32"/>
    </DeleteParameters>
    <UpdateParameters>
        <asp:Parameter Name="score" Type="Int32"/>
        <asp:Parameter Name="student_s_id" Type="Int32"/>
        <asp:Parameter Name="lesson_l_id" Type="Int32"/>
        <asp:Parameter Name="lesson_teacher_t_id" Type="Int32"/>
    </UpdateParameters>
</asp:SqlDataSource>